package com.hcmu.view.custome;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import com.telpoo.truyencuoi.R;
import com.hcmu.networklibs.rss.RSSItem;

public class RSSListAdapter extends ArrayAdapter<RSSItem> {

	private final Context context;
	private int resLayout;

    public RSSListAdapter(Context context, int textViewResourceId, List<RSSItem> items) {
        super(context, textViewResourceId, items);
        
        this.context = context;
        resLayout = textViewResourceId;
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        
        LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(resLayout, null);
        
        final RSSItem item = getItem(position); // == items.get(position)
        TextView tv = (TextView) v.findViewById(R.id.txtTitle);
        tv.setText(item.getTitle());
        return v;
    }
}